﻿#include <iostream>
#include <set>
using namespace std;
//set容器的大小和交换
//大小
void Printset(set<int>& s)
{
	for (set<int>::iterator it = s.begin(); it != s.end(); it++)
	{
		cout << *it << "  ";
	}
	cout << endl;
}
void test01()
{
	set<int> s1;
	s1.insert(10);
	s1.insert(70);
	s1.insert(20);
	s1.insert(50);
	//打印容器
	Printset(s1);
	//判断是否为空
	if(s1.empty())
	{ 
		cout << "容器为空" << endl;
	}
	else
	{
		cout << "容器大小为:" << endl;
		cout << s1.size() << endl;
	}
}
//交换
void test02()
{
	set<int>s1;
	s1.insert(10);
	s1.insert(70);
	s1.insert(20);
	s1.insert(50);
	set<int>s2;
	s2.insert(30);
	s2.insert(80);
	s2.insert(10);
	s2.insert(70);
	cout << "交换前:" << endl;
	cout << "s1为:";
	Printset(s1);
	cout << "s2为";
	Printset(s2);
	cout << "交换后:" << endl;
	s1.swap(s2);
	cout << "s1为:";
	Printset(s1);
	cout << "s2为";
	Printset(s2);
}
int main()
{
	test01();
	test02();
}